<?php
class AppController extends Controller{
	var $components = array('Auth','Cookie');
	
	function beforeFilter(){
		//find out user owned blogs
			$cookie = $this->Cookie->read('Auth.User');
			$userId = $cookie['id'];
			$this->loadModel('UsersBlog');
			$this->UsersBlog->unBindModel(array('belongsTo'=>array('User')));
			$dorimeBlogs = $this->UsersBlog->find('all',array(
				'conditions'=>array(
					'UsersBlog.users_id'=>$userId,
					'UsersBlog.status'=>'own'
					),
				'fields'=>array('Blog.id','Blog.title')
				));
			$this->set('dorimeBlogs',$dorimeBlogs);
	}
}
?>